home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / misc / wexmast / wvertical.pro < prev    next >
Text File  |  1997-07-08  |  2KB  |  81 lines

  1. ; $Id: wvertical.pro,v 1.3 1997/01/15 04:29:15 ali Exp $
  2. ;
  3. ; Copyright (c) 1993-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5.  
  6. ; This is the code for a simple vertical slider.  Moving the slider in
  7. ; this example causes the slider's new value to be printed in the IDL
  8. ; window.
  9. ;
  10. ; Sliders come in two varieties, horizontal (the default) and
  11. ; vertical.  For an example of a horizontal slider, see the routine
  12. ; WSLIDER.PRO.
  13.  
  14. ; Sliders are used to select integer values from
  15. ; a well-bounded range.  For example, a slider is a good widget
  16. ; to use for allowing users to select a color from an 8-bit palette.
  17. ; For an example of just such an application, see the routine
  18. ; WORLDROT.PRO available from the 'Simple Widget Examples' widget
  19. ; by selecting 'World Rotation Tool'.
  20.  
  21.  
  22.  
  23. PRO wvertical_event, event
  24. ; This is the event handler for a basic vertical slider.
  25.  
  26. ; Use WIDGET_CONTROL to get the user value of any widget touched and put
  27. ; that value into 'eventval':
  28.  
  29. WIDGET_CONTROL, event.id, GET_UVALUE = eventval
  30.  
  31. ; The movement of sliders is easily handled with a CASE statement.
  32. ; When the slider is moved, the value of 'eventval' becomes 'SLIDE':
  33.  
  34. CASE eventval OF
  35.     'SLIDE':BEGIN
  36.         
  37.         ; Get the current value of the slider and put it in the
  38.         ; variable 's':
  39.         WIDGET_CONTROL, event.id, GET_VALUE = s
  40.         
  41.         ; Print the slider value to the IDL window:
  42.         PRINT, s
  43.         END
  44. ENDCASE
  45. END
  46.  
  47.  
  48.  
  49. PRO wvertical, GROUP = GROUP
  50.  
  51. ; This is the procedure that creates a single slider.
  52.  
  53. ; A top-level base widget with the title "Vertical Slider Example" will
  54. ; hold the slider:
  55.  
  56. base = WIDGET_BASE(TITLE = 'Vertical Slider Example', /COLUMN)
  57.  
  58. ; Often, a slider's minimum and maximum values are defined by an expression:
  59.  
  60. minvalue = 0
  61. maxvalue = 100
  62.  
  63. ; A widget called 'slider' is created. It has the title 'Slider Widget', 
  64. ; a frame around it, and a User Value of 'SLIDE':
  65.  
  66. slider = WIDGET_SLIDER (base, $
  67.             MINIMUM = minvalue, $        ;The minimum value.
  68.             MAXIMUM = maxvalue, $        ;The maximum value.
  69.                 TITLE = 'Slider Widget', $    ;The slider title.
  70.             /FRAME, $            ;Put a frame around the slider.
  71.               UVALUE = 'SLIDE',$        ;Set the User Value to 'SLIDE'.
  72.             /VERTICAL, $            ;Make the slider vertical.
  73.             XSIZE = 300) 
  74.  
  75. ; Realize the widgets:
  76. WIDGET_CONTROL, base, /REALIZE
  77.  
  78. ; Hand off control of the widget to the XMANAGER:
  79. XMANAGER, "wvertical", base, GROUP_LEADER = GROUP, /NO_BLOCK
  80.  
  81. END